"""
@Project ：Python_Learning 
@File    ：70.爬楼梯.py
@IDE     ：PyCharm 
@Author  ：zhupp
@Date    ：2024/10/19 15:21 
"""


# class Solution:
#     def climbStairs(self, n: int) -> int:
#         if n <= 2:
#             return n
#         else:
#             return self.climbStairs(n-1) + self.climbStairs(n-2)


class Solution:
    def climbStairs(self, n: int) -> int:
        if n == 1:
            return 1
        if n == 2:
            return 2

        a, b = 1, 2

        for i in range(3, n + 1):
            a, b = b, a + b
        return b


s = Solution()
print(s.climbStairs(5))
